/**
 * 
 */
package org.lex.utils.collections;

import java.util.Enumeration;
import java.util.Iterator;

public class ArrayIterator<T> implements Iterator<T>, Enumeration<T> {
	private T[] array = null;
	private int from = 0;
	private int to = 0;

	public ArrayIterator(T[] array) {
		this(array, 0, array.length);
	}

	/**
	 * 
	 * @param array
	 * @param from
	 *            ����
	 * @param to
	 *            ������
	 */
	public ArrayIterator(T[] array, int from, int to) {
		this.array = array;
		this.from = from;
		this.to = to;
	}

	// implements Iterator
	public boolean hasNext() {
		return from < to;
	}

	public T next() {
		return array[from++];
	}

	public void remove() throws UnsupportedOperationException {
	}

	// implements Enumeration
	public boolean hasMoreElements() {
		return hasNext();
	}

	public T nextElement() {
		return next();
	}

}